﻿
@{
    ViewBag.Title = "系统日志";
    Layout = "~/Views/Shared/_Layout.cshtml";
}

<div class="wap-container">
    <nav class="breadcrumb" style="background-color:#fff;padding: 0 24px">
        首页
        <span class="c-gray en">/</span>
        系统管理
        <span class="c-gray en">/</span>
        系统日志
        <a class="btn btn-success radius f-r" style="line-height:1.6em;margin-top:3px" href="javascript:location.replace(location.href);" title="刷新"><i class="Hui-iconfont">&#xe68f;</i></a>
    </nav>
    <article class="Hui-admin-content clearfix">
        <div class="panel mt-20">
            <div class="panel-body">
                <div class="layui-btn-group table-btn">
                    <button class="layui-btn layui-btn-danger" data-type="del">删除日志</button>
                </div>
                <div class="mt-20 clearfix">
                    <table class="layui-table" id="logform" lay-filter="logform"></table>
                </div>
            </div>
        </div>
    </article>
</div>

@section FooterScript
{
    <script type="text/javascript">
        layui.use(['table', 'layer'], function () {
            var table = layui.table,
                layer = layui.layer,
                $ = layui.$,
                active = {
                    del: function () {
                        layer.confirm('是否确定要删除最近7天前的日志？', {
                            btn: ['确定', '取消']
                        }, function (index, layero) {
                            $.ajax({
                                url: '/SystemManage/SystemLog/BatchDelete',
                                type: 'POST',
                                success: function (res) {
                                    if (res.code == 200) {
                                        layer.msg(res.data)
                                    } else {
                                        layer.msg(res.errorMsg)
                                    }
                                },
                                fail: function () {
                                    layer.msg('网络错误')
                                }
                            })
                        })
                    }
                };

            table.render({
                elem: '#logform',
                url: '/SystemManage/SystemLog/ListData',
                request: {
                    page: 1,
                    limit: 10
                },
                page: true,
                cols: [[
                    { field: 'id', width: 80, title: 'ID', hide: true },
                    { field: 'message', title: '内容' },
                    { field: 'userName', title: '用户名' },
                    { field: 'loginIP', title: '客户端IP' },
                    { field: 'addTime', title: '时间' }
                ]],
                response: {
                    statusCode: 200,
                    countName: "totalCount"
                }
            })

            $('.table-btn .layui-btn').on('click', function () {
                var type = $(this).data('type');
                active[type] ? active[type].call(this) : '';
            })
        })
    </script>
}

